﻿/*
///    This file is part of BannerLib4Net.
///
///    BannerLib4Net is free software: you can redistribute it and/or modify
///    it under the terms of the GNU General Public License as published by
///    the Free Software Foundation, either version 3 of the License, or
///    (at your option) any later version.

///    BannerLib4Net is distributed in the hope that it will be useful,
///    but WITHOUT ANY WARRANTY; without even the implied warranty of
///    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
///    GNU General Public License for more details.
///
///    You should have received a copy of the GNU General Public License
///    along with BannerLib4Net.  If not, see <http://www.gnu.org/licenses/>.
*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BannerLib4Net.Core.Logging.Log4Net;
using log4net;
using log4net.Config;
using System.Configuration;

namespace BannerLib4Net.Core.Logging
{
    public class LoggingFactory
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(LoggingFactory));

        static LoggingFactory()
        {

        }

        public static ILogger GetLogger(String name)
        {
            ILogger logger = null;

            BasicConfigurator.Configure();

            String configImplementation = ConfigurationManager.AppSettings["logger.implementation"];

            if (String.IsNullOrEmpty(configImplementation))
            {
                configImplementation = "log4net";
            }

            switch (configImplementation.ToLower())
            {
                case "log4net":
                    logger = new Log4NetLogger(name);
                    break;
                default:
                    log.Debug(String.Format("Could not find a configured logger implementation. Using the default log4net logger"));
                    logger = new Log4NetLogger(name);
                    break;
            }

            return logger;

        }

    }
}
